﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class GM : MonoBehaviour
{
    static GM instance;
    public Text time;
    public GameObject GameOverUI;
    public GameObject Pause;
    public GameObject StartUI;
    private void Start(){
        Time.timeScale=0f;
        if(instance!=null){
            Destroy(gameObject);
        }
        instance=this;
    }

    void Update()
    {
        time.text=Time.timeSinceLevelLoad.ToString("00");
    }
    public void RestartGame(){
        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        instance.StartUI.SetActive(false);
        Time.timeScale=1;
    }
    public void Quit(){
        Application.Quit();
    }
    public  static void GameOver(bool dead){
        if(dead){
            instance.GameOverUI.SetActive(true);
            Time.timeScale=0f;
        }
    }
    public  static void puase(){
        Time.timeScale=0;
        instance.Pause.SetActive(true);
    }
    public  static void Resume(){
        Time.timeScale=1;
        instance.Pause.SetActive(false);
    }
    public  static void GameStart(){
        Time.timeScale=1f;
        instance.StartUI.SetActive(false);
    }
}
